<template>
  <el-container>
    <!-- 侧边导航栏 -->
    <el-aside width="200">
      <h1 class="logo" style="height: 60px">Logo</h1>
      <el-menu
        :default-active="$route.path"
        class="el-menu-vertical-demo"
        @open="handleOpen"
        @close="handleClose"
        :collapse="isCollapse"
      >
        <qf-sub-menu :sideMenu="$store.state.sideMenu"></qf-sub-menu>
      </el-menu>
    </el-aside>
    <el-container>
      <!-- 顶部 -->
      <el-header>
        <el-row type="flex" class="row-bg" justify="space-around">
          <el-col :span="6"
            ><div class="icon">
              <i
                :class="isCollapse ? 'el-icon-s-unfold' : 'el-icon-s-fold'"
                @click="isCollapse = !isCollapse"
              ></i></div
          ></el-col>
          <el-col :span="6"
            ><div class="grid-content bg-purple-light">
              项目管理系统
            </div></el-col
          >
          <el-col :span="6">
            <b class="grid-content bg-purple">头像</b>|
            <b class="quit"><a href="" @click="quit">退出</a></b>
          </el-col>
        </el-row>
      </el-header>
      <!-- 内容区 -->
      <el-main>
        <div class="beardCrum">
          <el-breadcrumb separator="/">
          <el-breadcrumb-item :to="{path:'/welcome'}">首页</el-breadcrumb-item>
            <el-breadcrumb-item v-for="item in $store.state.breadCrum" :to="{name:item.name}">{{item.meta.name}}</el-breadcrumb-item>
          </el-breadcrumb>
        </div>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>
<script>
import { getlog } from "@/api";
export default {
  data() {
    return {
      // 侧栏
      isCollapse: false,
    };
  },

  methods: {
    // 顶部
    quit(e) {
      e.preventDefault(); //阻止a标签默认事件
      //退出登录
      // 1、跳转到登陆页面
      this.$router.push("/login");
      // 2、清空token
      localStorage.removeItem("pm-token");
      // 3、刷新页面 目的：因为addRoutes之后，数据编译无法清空，会导致不同用户菜单混乱
      location.reload();
    },
    // 侧栏
    handleOpen(key, keyPath) {
      // console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      // console.log(key, keyPath);
    },
  },
  beforeCreate() {
    getlog().then((res) => {
      // console.log(res);
    });
  },
};
</script>

<style>
/* 侧边 */
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}
.el-aside {
  background-color: #2ee2e27e;
  color: #333;
  text-align: center;
  line-height: 60px;
}
.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
/* 顶部 */
.icon {
  cursor: pointer;
  text-align: left;
  font-size: 40px;
}
.el-header,
.el-footer {
  background-color: rgba(9, 143, 167, 0.527);
  color: #333;
  text-align: center;
  line-height: 60px;
}
.el-container {
  margin-bottom: 40px;
  height: 100%;
}
/* 内容 */
.el-main {
  background-color: #bad2ee;
  color: #333;
  text-align: center;
  /* line-height: 60px; */
}
</style>